<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>增加预约</title>
<jsp:include page="/WEB-INF/backstage/util.jsp"/>
</head>
<body>
	<form class="form-horizontal" id="form" method="post">
					<input type="hidden" name="shop_id" value="${shop_id }">
					<input type="hidden" name="project_id" value="${b.project_id }">
					<button type="button" class="btn btn-primary" onclick="selectProject()">
							<span class="glyphicon glyphicon-plus"></span>选着项目
					</button>
					<div class="form-group">
						<label for="mobile" class="col-sm-2 control-label">顾客账号</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="mobile"
								name="mobile" placeholder="请输入要预约的顾客账号">
						</div>
					</div>		
					<div class="form-group">
						<label for="order_content" class="col-sm-2 control-label">消费内容</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="order_content"
								name="order_content" readonly="readonly" value="${b.project_name }">
						</div>
					</div>		
					<div class="form-group">
						<label for="order_money" class="col-sm-2 control-label">护理价格</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="order_money"
								name="order_money" readonly="readonly" value="${b.rmb_price }" >
						</div>
					</div>		
					<div class="form-group">
						<label for="subscribe_time" class="col-sm-2 control-label">预约时间</label>
						<div class="col-sm-10">
							<input type="date" class="form-control" id="subscribe_time"
								name="subscribe_time" >
						</div>
					</div>		
					<div class="form-group">
						<label for="order_remark" class="col-sm-2 control-label">订单备注</label>
						<div class="col-sm-10">
							<textarea id="order_remark" name="order_remark" cols="45" rows="20"></textarea>
						</div>
					</div>		
					<button type="button" class="btn btn-info" onclick="Save_Subsrcible()">
							<span class="glyphicon glyphicon-plus"></span>保存
					</button>
				</form>
</body>
<script>
	function Save_Subsrcible(){
		var bootstrapValidator = $("#form").data('bootstrapValidator'); //获取表单对象
		bootstrapValidator.validate();//触发全部验证 
		if(bootstrapValidator.isValid()){
			form.action="${pageContext.request.contextPath }/proltal/subsrcibe/saveSubsrcibe";
			form.submit();
		}
	}
	
	function selectProject(){
		 location.href="${pageContext.request.contextPath }/proltal/subsrcibe/selectNurseProject?shop_id=${shop_id}"; 
	} 
	
	$(function(){
	$("#form").bootstrapValidator({
		live : 'enabled',
		feedbackIcons : { //验证时显示的图标
			valid : 'glyphicon glyphicon-ok', //正确图标
			invalid : 'glyphicon glyphicon-remove', //错误图标
			validating : 'glyphicon glyphicon-refresh' //正在更新图标
		},
		fields : { //要验证哪些字段
			mobile : {
				validators : {//验证
					notEmpty : { //非空判断
						message : '客户账号不能为空' //验证错误时的信息，
					},
					 remote : {
							message : '客户不存在',
							url : '${pageContext.request.contextPath }/proltal/subsrcibe/checkCustomName',
							type : 'post',
							delay : 2000,//每输入一个字符，就发ajax请求，服务器压力还是太大，设置2秒发送一次ajax（默认输入一个字符，提交一次，服务器压力太大）
							data:function(validator){
								return{
									mobile:$("#mobile").val()
								}
							}
						} 
				},
			},	
			order_content : {
				validators : {//验证
					notEmpty : { //非空判断
						message : '请选择一个项目' //验证错误时的信息，
					},
				},
			},	
			subscribe_time:{
				validators : {//验证
					notEmpty : { //非空判断
						message : '请填写预约时间' //验证错误时的信息，
					},
				},
			}
		}
	});
});

</script>
</html>